package com.dotfunny;

import java.util.List;
import java.net.URL;
import com.sun.syndication.feed.synd.*;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;

final class RSSParser {
	
	/**
	 * @param args
	 */
	private String _url = "http://rss.slashdot.org/Slashdot/slashdot";
	private SyndFeedInput _input;
	private SyndFeed _feed;
	public RSSParser(String url)
	{
		try
		{
			if (url != null)
			{
				_url = url;
				URL feedURL = new URL(_url);
				_input = new SyndFeedInput();
				_feed = _input.build(new XmlReader(feedURL));
			}
		}
		catch(Exception e)
		{
			//TODO
		}
	}
	public List getEntries()
	{
		return _feed.getEntries();
	}
	
	public static void main(String[] args) throws Exception
	{
		// TODO Auto-generated method stub
		System.out.println("This is a unit test from RSSParser.");
		URL feedURL = new URL("http://rss.slashdot.org/Slashdot/slashdot");
		SyndFeedInput input = new SyndFeedInput();
		SyndFeed feed = input.build(new XmlReader(feedURL));
		System.out.println(((SyndEntry)feed.getEntries().get(0)).getTitle());
		System.out.println("-------end------");
	}

}
